package cn.huiyunche.base.service.interfaces.impl;

import cn.huiyunche.base.service.interfaces.CWaybillStatusLogService;
import cn.huiyunche.base.service.mappers.CWaybillStatusLogMapper;
import cn.huiyunche.base.service.mappers.ext.CWaybillStatusLogViewMapper;
import cn.huiyunche.base.service.model.CWaybillStatusLog;
import cn.huiyunche.tools.basic.exceptions.BusinessException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 运单日志记录表
 *
 * @author Administrator
 */
@Service
public class CWaybillStatusLogServiceImpl implements CWaybillStatusLogService {

    private static final Logger LOGGER = LoggerFactory.getLogger(CWaybillStatusLogServiceImpl.class);

    @Autowired
    private CWaybillStatusLogMapper cWaybillStatusLogMapper = null;

    @Autowired
    private CWaybillStatusLogViewMapper cWaybillStatusLogViewMapper = null;

    public CWaybillStatusLogViewMapper getCWaybillStatusLogViewMapper() {
        return this.cWaybillStatusLogViewMapper;
    }

    public CWaybillStatusLogMapper getCWaybillStatusLogMapper() {
        return this.cWaybillStatusLogMapper;
    }

    /**
     * 添加运单日志
     *
     * @param log
     * @return
     */
    @Override
    public int addCWaybillStatusLog(CWaybillStatusLog log) {
        LOGGER.info("addCWaybillStatusLog params : {}", log);
        try {
            return this.getCWaybillStatusLogMapper().insertSelective(log);
        } catch (Exception e) {
            LOGGER.error("create cwaybill insert status log error : {}.", e);
            throw new BusinessException("添加运单日志异常");
        }
    }

    /**
     * 批量插入 运单日志
     *
     * @param list
     */
    @Override
    public int batchInsert(List<CWaybillStatusLog> list) {
        return this.getCWaybillStatusLogViewMapper().batchInsert(list);
    }

}
